<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:users="http://java.sun.com/jsf/composite/users"
    template="../usersTemplate.xhtml">
    <ui:define name="title">
        Postavljanje aplikacije
    </ui:define>
    <ui:define name="center">

        <h:form>    
            <p:growl id="messages" life="2000" showDetail="true"/>
               <p:panel widgetVar="panel" header="Postavljanje aplikacije"> 
                   
                    <h:panelGrid columns="2" cellpadding="3">  
                        <h:outputText value="Naziv aplikacije: *" />  
                        <p:inputText size="50" label="appName" id="appName" 
                                     value="#{uploadManagedBean.application.name}"><p:focus/><p:watermark for="appName" value="Upisite naziv aplikacije"/></p:inputText>  

                        <h:outputText value="Opis aplikacije: *" />  
                        <p:inputTextarea style="width:300px;height:100px;" id="appDescription" label="appDescription"  
                                         value="#{uploadManagedBean.application.description}"><p:watermark for="appDescription" value="Kratak opis aplikacije"/></p:inputTextarea>

                        <h:outputText value="Minimalni API level: *" /> 
                        <h:selectOneMenu id="minAndReq" value="#{uploadManagedBean.application.minAndReq}">
                            <f:selectItem itemValue="3" itemLabel="3"></f:selectItem>
                            <f:selectItem itemValue="4" itemLabel="4"></f:selectItem>
                            <f:selectItem itemValue="7" itemLabel="7"></f:selectItem>
                            <f:selectItem itemValue="8" itemLabel="8"></f:selectItem>
                            <f:selectItem itemValue="10" itemLabel="10"></f:selectItem>
                            <f:selectItem itemValue="11" itemLabel="11"></f:selectItem>
                        </h:selectOneMenu>  
                    </h:panelGrid>  
                    <br/>
                    <h:panelGrid columns="3" cellpadding="3">

                        <h:outputText value="Slika #1: " />  
                        <p:graphicImage id="gi1" height="40" width="40" value="#{uploadManagedBean.image1}"/>
                        <p:fileUpload id="uploadImage1" fileUploadListener="#{uploadManagedBean.uploadImage1}"   
                                      allowTypes="*.jpg;*.png;*.gif;" description="Images" update="messages,gi1"/> 

                        <h:outputText value="Slika #2: " />
                        <p:graphicImage id="gi2" height="40" width="40" value="#{uploadManagedBean.image2}"/>
                        <p:fileUpload id="uploadImage2" fileUploadListener="#{uploadManagedBean.uploadImage2}"   
                                      allowTypes="*.jpg;*.png;*.gif;" description="Images" update="messages,gi2"/> 

                        <h:outputText value="Aplikacija: " />  
                        <h:outputText id="filename" value="#{uploadManagedBean.filename}"/>
                        <p:fileUpload id="uploadApk" fileUploadListener="#{uploadManagedBean.uploadApk}"   
                                      allowTypes="*.apk;" description="apks" update="messages,filename"/> 
                        <p:ajaxStatus>  
                            <f:facet name="start">  
                                <h:graphicImage style="width: 30px;height: 30px;" value="../images/spinner.gif" />  
                            </f:facet>  

                            <f:facet name="complete">  
                                <h:outputText value="" />  
                            </f:facet>  
                        </p:ajaxStatus>  
                        <p:commandButton value="Sacuvaj" action="#{uploadManagedBean.saveApk}" update="messages"/> 
                        <p:commandButton value="Reset" action="#{uploadManagedBean.reset()}" ajax="false"/>
                    </h:panelGrid>  
                </p:panel>
        </h:form>
    </ui:define>
</ui:composition>